package com.developpez.rpouiller.testsjunit4.testPatch;

import org.junit.Assert;
import org.junit.Test;

import com.developpez.rpouiller.testsjunit4.testPatch.Operations;


public class TestSimple {


    /** 
     * test d'addition de 2 nombres 
     */
    @Test
    public void additionAvecDeuxNombres() {
        final long lAddition = Operations.additionner(new long[]{10, 20});
        Assert.assertEquals(30, lAddition);
    }

    /** 
     * test d'addition de 5 nombres 
     */
    @Test
    public void additionAvecCinqNombres() {
        final long lAddition = Operations.additionner(new long[]{256, 512, 1024, 2048, 4096});
        Assert.assertEquals(7936, lAddition);
    }


    /** 
     * test de multiplication de 2 nombres => Changer l'Assert (300 => 200)
     */
    @Test
    public void mutiplicationAvecDeuxNombres() {
        final long lMultiplication = Operations.multiplier(new long[]{10, 20});
        Assert.assertEquals(200, lMultiplication);
    }
 
    /** 
     * test de multiplication de 5 nombres ==> Changer Operations.additioner en Operations.multiplier
     */   
    @Test
    public void testMutiplicationAvecCinqNombres() {
        final long lMultiplication = Operations.multiplier(new long[]{256, 512, 1024, 2048, 4096});
        Assert.assertEquals(1125899906842624L, lMultiplication);
    }
    
    /**
     * test de la soustraction
     */
    @Test
    public void testSoustractionAvecTroisNombres() {
    	final double lSoustraction = Operations.soustraire(new long[]{5, 3, 1});
    	Assert.assertEquals(1, lSoustraction, 5);
    }
    
    @Test(expected=IllegalArgumentException.class)
    public void testSoustractionAvecMoinsDeDeuxNombres() {
    	final double lSoustraction = Operations.soustraire(new long[]{5});
    }
    
    @Test
    public void testPythagoreCorrect() {
    	final Boolean[] lPythagore = Operations.pythagore(new long[][]{{3 ,4, 5}});
    	Assert.assertEquals(true, lPythagore[0]);
    }
    
    @Test
    public void testPythagoreAvecDeuxTriangles() {
    	final Boolean[] lPythagore = Operations.pythagore(new long[][]{{3 ,4, 5},{10, 2, 5}});
    	Assert.assertEquals(true, lPythagore[0]);
    	Assert.assertEquals(false, lPythagore[1]);
    }
    
    @Test(expected=IllegalArgumentException.class)
    public void testPythagoreIncorrect() {
    	final Boolean[] lPythagore = Operations.pythagore(new long[][]{{3}});
    }
    
    @Test
    public void testDivisionCorrecte() {
    	final long lDivision = Operations.diviser(new long[]{4,2});
    	Assert.assertEquals(2, lDivision);
    }
    
    @Test(expected=IllegalArgumentException.class)
    public void testDivisionIncorrecte() {
    	final long lDivision = Operations.diviser(new long[]{2});
    }
	

}
